package com.naive.imperative.program.operations;

import com.naive.imperative.program.BinaryOperation;
import com.naive.imperative.program.ExecutionContext;


public class Divide extends BinaryOperation<Double, Double> {
	@Override
	public Double evaluate(ExecutionContext x) {
		double v = getOperandB().evaluate(x).doubleValue();
		if (v == 0.) {
			// TODO: use checked exceptions and add 
			// some context instrumentation into each evaluate and
			// execute
			throw new RuntimeException();
		}
		return getOperandA().evaluate(x).doubleValue() / v;
	}

}
